home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
327
< prev
next >
Wrap
Internet Message Format
|
1996-08-06
|
3KB
Path: lyra.csx.cam.ac.uk!nmm1
From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.std.c
Subject: Re: Binary Mode stdin/stdout
Date: 8 Feb 1996 10:26:55 GMT
Organization: University of Cambridge, England
Message-ID: <4fcj5f$2ft@lyra.csx.cam.ac.uk>
References: <4f67kg$11g@cortex.dialin.rrze.uni-erlangen.de> <DME74w.4M4@stdc.demon.co.uk> <4fbnr3$veg@usenet.pa.dec.com>
NNTP-Posting-Host: ursa.cus.cam.ac.uk
In article <4fbk81$qk@cortex.dialin.rrze.uni-erlangen.de>, mskuhn@unrza3.dialin.rrze.uni-erlangen.de (Markus Kuhn) writes:
|> clive@stdc.demon.co.uk (Clive D.W. Feather) writes:
|>
|> >In article <4f67kg$11g@cortex.dialin.rrze.uni-erlangen.de>,
|> >Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de> wrote:
|> >> Why isn't there a standard way of allowing an ISO C program to switch
|> >> the standard input and output into binary transparent mode (as with
|> >> the "b" flag in fopen()/freopen() for normal files)?
|> >>
|> >> Has this just been forgotten or is there a good technical reason?
|>
|> >On some implementations, this decision has to be made at the time you
|> >open the file and can't be changed.
|>
|> I would already be happy with a portable function that allows to
|> switch stdin or stdout to binary mode and that has only a well-defined
|> behaviour according to the standard if this switch occurs before any
|> byte has been written to or read from the stream. This would cause no
|> headaches on your computing fossil (because inserting a newline during
|> a later switch would not be non-conforming) and would be sufficient
|> for all important applications I can think of (like zcat).
In article <4fbnr3$veg@usenet.pa.dec.com>, diamond@tko.dec.com (Norman Diamond) writes:
|>
|> I'll take your word for it. I suppose the operating system would require
|> the program to close the file and reopen it, so that is what the C standard
|> requires the C program to do. (This is also why the C standard requires C
|> programs to simulate long int arithmetic on their own instead of building
|> it into the language, since some hardware doesn't have it, right?)
Sorry, but these wouldn't work even on UNIX. Not all 'files' can
be closed and reopened - think of rewinding tapes, for example!
Even on MVS, it would be possible to have a run-time flag that
selected between binary and text for stdin and stdout, but this
would have nothing to do with the C standard. When I wrote my
interface, I never provided this because I regarded it as being
more confusion than it was worth - remember that C binary I/O
does not map well onto MVS sequential files.
Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email: nmm1@cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679